<?php
    use User\Model\CardModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        选择题工具列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="/User/Applications/selectAdd">增加</a>
            </header>
            <div class="panel-body">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">名称</th>
                        <th width="20%">描述</th>
                        <th width="7%">正方描述</th>
                        <th width="7%">反方描述</th>
                        <th width="12%">状态</th>
                        <th width="12%">地址</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['desc'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['a_name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $val['b_name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo CardModel::get_status($val['status']);?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word">
                                <?php echo $_SERVER['SERVER_NAME'] . '/Wap/Applications1/select?id=' . $val['id'];?>
                            </span>
                        </td>
                        <td>
                            <div>
                                <a class="btn btn-default"
                                   href="<?php echo '/User/Applications/selectUpdate?type=update&id=' . $val['id'];?>">编辑</a>
                                <a class="btn btn-danger" href="#"
                                   onclick="<?php echo 'return delete_data(' . $val['id'] .')';?>">删除</a>
                                <a class="btn btn-success" href="#"
                                   onclick="<?php echo 'return pass_data(' . $val['id'] .')';?>">发布</a>
                            </div>
                            <div style="margin-top: 10px;">
                                <a class="btn btn-warning" href="#"
                                   onclick="<?php echo 'return unpass_data(' . $val['id'] .')';?>">停用</a>
                                <a class="btn btn-info"
                                   href="<?php echo '/User/Applications/selectShare?id=' . $val['id'];?>">分享设置</a>
                            </div>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{
                id:id,
                name:'tool_ans'
            },
            dataType:'json',
            url:'/User/Applications/delete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function pass_data(id){
        $.ajax({
            data:{
                id:id,
                name:'tool_ans'
            },
            dataType:'json',
            url:'/User/Applications/pass',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function unpass_data(id){
        $.ajax({
            data:{
                id:id,
                name:'tool_ans'
            },
            dataType:'json',
            url:'/User/Applications/unpass?',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
</script>